package com.chencong.entity;

import java.util.Objects;

/**
 * @author chencong
 * @date 2020/12/14 下午1:29
 */
public class User {

    private int id;
    private String name;
    private String pwd;
    private String pwdConfirm = pwd;
    private int userType;
    private String userTypeStr = userType == 0 ? "普通用户" : "经理";

    public User(int id, String name, String pwd, String pwdConfirm, int userType) {
        this.id = id;
        this.name = name;
        this.pwd = pwd;
        this.pwdConfirm = pwdConfirm;
        this.userType = userType;
    }

    public User(int id, String name, String pwd, String pwdConfirm, int userType, String userTypeStr) {
        this.id = id;
        this.name = name;
        this.pwd = pwd;
        this.pwdConfirm = pwdConfirm;
        this.userType = userType;
        this.userTypeStr = userTypeStr;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return Objects.equals(name, user.name) &&
                Objects.equals(pwd, user.pwd);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, pwd, userType);
    }

    public User() {
    }

    public User(int id, String name, String pwd, int userType) {
        this.id = id;
        this.name = name;
        this.pwd = pwd;
        this.userType = userType;
        this.userTypeStr = userType == 0 ? "普通用户" : "经理";
    }

    /**
     * 获取
     *
     * @return id
     */
    public int getId() {
        return id;
    }

    /**
     * 设置
     *
     * @param id
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * 获取
     *
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     *
     * @return pwd
     */
    public String getPwd() {
        return pwd;
    }

    /**
     * 设置
     *
     * @param pwd
     */
    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    /**
     * 获取
     *
     * @return userType
     */
    public int getUserType() {
        return userType;
    }

    /**
     * 设置
     *
     * @param userType
     */
    public void setUserType(int userType) {
        this.userType = userType;
        this.userTypeStr = userType == 0 ? "普通用户" : "经理";
    }


    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", pwd='" + pwd + '\'' +
                ", pwdConfirm='" + pwdConfirm + '\'' +
                ", userType=" + userType +
                ", userTypeStr='" + userTypeStr + '\'' +
                '}';
    }

    /**
     * 获取
     *
     * @return pwdConfirm
     */
    public String getPwdConfirm() {
        return pwdConfirm;
    }

    /**
     * 设置
     *
     * @param pwdConfirm
     */
    public void setPwdConfirm(String pwdConfirm) {
        this.pwdConfirm = pwdConfirm;
    }

    /**
     * 获取
     *
     * @return userTypeStr
     */
    public String getUserTypeStr() {
        return userTypeStr;
    }

    /**
     * 设置
     *
     * @param userTypeStr
     */
    public void setUserTypeStr(String userTypeStr) {
        this.userTypeStr = userType == 0 ? "普通用户" : "经理";
    }

    public void setUserTypeStr() {
        userTypeStr = userType == 0 ? "普通用户" : "经理";
    }
}